package com.ethan.java8;

import java.util.Arrays;
import java.util.concurrent.ThreadLocalRandom;

/**
 * @author ethan
 * create 2018-08-03 上午11:40
 * desc 并行(parallel)
 **/
public class java9 {
    public static void main(String[] args){
        long[] arrayOfLong = new long[20000];


        Arrays.parallelSetAll( arrayOfLong,
                index -> ThreadLocalRandom.current().nextInt( 1000000 ) );
        Arrays.stream( arrayOfLong ).limit( 10 ).forEach(
                i -> System.out.print( i + " " ) );
        System.out.println();

        Arrays.parallelSort( arrayOfLong );
        Arrays.stream( arrayOfLong ).limit( 10 ).forEach(
                i -> System.out.print( i + " " ) );
        System.out.println();

    }
}
